package com.weiyi.mashangzhu.Roomer.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Bean.SortModel;

import java.util.List;

/**
 * Created by win7 on 2017/10/24.
 */

public class CityReminderAdapter extends BaseAdapter{
    Context context;
    List<SortModel> sortModelList;

    public CityReminderAdapter(Context context, List<SortModel> sortModelList) {
        this.context = context;
        this.sortModelList = sortModelList;
    }

    @Override
    public int getCount() {
        return sortModelList.size();
    }

    @Override
    public Object getItem(int position) {
        return sortModelList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if (convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_next,null);
            viewHolder=new ViewHolder();
            viewHolder.name= (TextView) convertView.findViewById(R.id.tv);
            viewHolder.next= (ImageView) convertView.findViewById(R.id.img);
            convertView.setTag(viewHolder);
        }
        viewHolder= (ViewHolder) convertView.getTag();
        viewHolder.name.setText(sortModelList.get(position).getName()+"");
        viewHolder.next.setVisibility(View.GONE);
        return convertView;
    }
    class ViewHolder{
        TextView name;
        ImageView next;
    }
}
